package org.idontknow.singleton;

import java.lang.CloneNotSupportedException;

class SingletonObject {

  private static SingletonObject ref = null;

  private SingletonObject() {
    System.out.println("In process of creating THE ONLY SingletonObject...");
  }

  public static synchronized SingletonObject getSingletonObject() {
    if(ref == null) {
      System.out.println("o...Singleton is not created yet, you got it now:)");
      ref = new SingletonObject();
    }
    else
      System.out.println("haha! you've got it already, il give you the same");
    return ref;
  }

  public Object clone() throws CloneNotSupportedException{
    System.out.println("ha~~i got u! DO NOT try to clone me :p");
    throw new CloneNotSupportedException();
  }
}

    
